home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / INTERRUP.SWG / 0015_Disable the pause key.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  5KB  |  101 lines

  1. { Updated KEYBOARD.SWG on January 27, 1994 }
  2.  
  3. UNIT NoPause;                {  Unit to disable the pause key                }
  4.                         {  Last Updated  Apr 26/93                      }
  5.                         {  Copyright (C) Greg Estabrooks, 1993          }
  6. INTERFACE
  7. {***********************************************************************}
  8. USES DOS;                       { IMPORT SetIntVec,GetIntVec.           }
  9. VAR
  10.      OldExit   :POINTER;        {  To hold pointer to old exit proc     }
  11.      OldInt09  :POINTER;        {  To hold old int 9h handler           }
  12.  
  13. PROCEDURE ForgetPauses;
  14. FUNCTION PausePressed :WORD;    { Returns number of times pause was     }
  15.                                 { Since last time ForgetPauses was called.}
  16. {***********************************************************************}
  17. IMPLEMENTATION
  18. VAR
  19.      NumPauses :WORD;           {  To hold number of times pause        }
  20.                                 {  was pressed. Not Directly accessible }
  21.                                 {  by other processes.                  }
  22. PROCEDURE ForgetPauses; ASSEMBLER;
  23.                        {  Routine to Clear Pause counter variable       }
  24. ASM
  25.   Mov NumPauses,0               {  Clear Pause Variable                 }
  26. END;{ForgetPauses}
  27.  
  28. FUNCTION PausePressed :WORD; ASSEMBLER;
  29.                       { Function to return number of times pause pressed}
  30. ASM
  31.   Mov AX,NumPauses              {  Load number of pauses into register  }
  32. END;{PausePressed}
  33.  
  34. PROCEDURE TrapPause; ASSEMBLER;
  35. ASM
  36.   Push DS
  37.   Push AX
  38.   Push ES
  39.   Mov AX,Seg @Data              {  Allow us to access numpauses.        }
  40.   Mov DS,AX
  41.   Mov AX,$40                    {  Point ES, to bios data area          }
  42.   Mov ES,AX
  43.   Mov AH,ES:[$18]               {  Put keyboard shift flags into AH     }
  44.   And AH,8                      {  Clear all but potential pause flags  }
  45.   Or AH,0                       {  Check for zero                       }
  46.   Jz @NormalKey                 {  If it was zero pause wasn't pressed  }
  47.   Add NumPauses,1               {  Add 1 to number of pauses pressed    }
  48.   Mov AH,ES:[$18]               {  Load Flags again                     }
  49.   And AH,$F7                    {  Clear pause flags                    }
  50.   Mov ES:[$18],AH               {  Load new flags byte back into bios   }
  51. @NormalKey:
  52.   PushF                         {  Push flags onto stack                }
  53.   Call [OldInt09]               {  Call old Int 9h handler              }
  54. @Exit:
  55.   Sti                           {  Allow Interrupts                     }
  56.   Pop ES                        {  Restore registers that were used     }
  57.   Pop AX
  58.   Pop DS
  59.   IRet                          {  Return from interrupt                }
  60. END;{TrapPause}
  61.  
  62. {$F+}
  63. PROCEDURE Restore_Pause;
  64.                        {  Routine to restore int 9  and exit pointers   }
  65. BEGIN
  66.   SetIntVec(9,OldInt09);        { Restore Int pointer to old pointer    }
  67.   ExitProc := OldExit;          { Restore Exit Pointer                  }
  68. END;{Restore_Pause}
  69. {$F-}
  70.  
  71. PROCEDURE InitTrap;
  72.                    {  Routine to set Int pointers to TrapPause          }
  73. BEGIN
  74.   GetIntVec(9,OldInt09);        {  Get pointer to Old Int 9h            }
  75.   SetIntVec(9,@TrapPause);      {  Point Int 9 to TrapPause             }
  76.   OldExit := ExitProc;          {  Save Old Exit Pointer                }
  77.   ExitProc := @Restore_Pause;   {  Set exit Pointer to new exit         }
  78. END;{InitTrap}
  79.  
  80. BEGIN
  81.   InitTrap;                        { Set up New Int 9h Handler             }
  82. END.{***********************************************************************}
  83. PROGRAM ShowNoPause;            { Demo of NoPause Unit. Greg Estabrooks.}
  84. USES CRT,                       { IMPORT Clrscr,KeyPressed,ReadKey.     }
  85.      NoPause;                   { Unit containing Pause routines.       }
  86. VAR
  87.    Misc :WORD;                  { Holds changing number to show the system}
  88.                                 { is not paused.                        }
  89. BEGIN
  90.   Clrscr;                       { Clear screen clutter.                 }
  91.   ForgetPauses;                 { Clear the pauses number holder.       }
  92.   Misc := 0;                    { Clear Counter.                        }
  93.   REPEAT                        { Loop Until a key other than Pause is  }
  94.                                 { pressed.                              }
  95.     GOTOXY(1,1);                { Always show info at top corner.       }
  96.     Write(Misc:8,'...  You have pressed pause ',PausePressed:3,' times.');
  97.     INC(Misc);                  { Increase counter to show a change.    }
  98.   UNTIL KeyPressed;
  99. END.{ShowNoPause};
  100. {***********************************************************************}
  101.